package com.woniuxy.rabbitmq.receiver;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @Author: wanghao
 * @Date: 2019/9/11 15:22
 */
@Component
public class FirstReceiver {
    @RabbitListener(queues = {"first-queue", "second-queue"}, containerFactory = "rabbitListenerContainerFactory")
    public void handleMessage(Message message, Channel channel) throws Exception {
        // 处理消息
        System.out.println("FirstConsumer {} handleMessage :" + new String(message.getBody()));
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),true);

    }

}
